import java.io.*;
import java.net.*;
public class WebServer{
private void run(){
try {
ServerSocket serverSocket = new ServerSocket(5520);
while(true){
try {
Socket serverClient = serverSocket.accept();
WebServerThread wst = new WebServerThread(serverClient);
wst.start();
} catch (IOException evt) {
System.out.println("Error");
}
}
} catch (IOException evt) {
System.out.println("error");
}
}
public static void main(String[] args) {
WebServer ws = new WebServer();
System.out.println("Server is up and running.");
ws.run();
}
}
import java.io.*;
import java.net.*;
import java.lang.*;
class WebServerThread extends Thread {
Socket serverClient;
BufferedReader in = null;
public WebServerThread(Socket clientSocket) {
serverClient = clientSocket;
}
public void run() {
try {
in = new BufferedReader(new InputStreamReader(serverClient.getInputStream()));
//System.out.println(in.readLine());
HTTP http = new HTTP(in.readLine(), serverClient);
in.close();
serverClient.close();
} catch (IOException e) {
System.out.println("Error");
} catch (NullPointerException e){
System.out.println("bad");
}
}
}
import java.io.*;
import java.nio.Buffer;
import java.util.StringTokenizer;
import java.net.*;
public class HTTP {
String contentTypeLine;
String file;
String version = "HTTP/1.1";
//String crlf = "\\r\\n";
String statusLine;
String responseHeader;
String statusCodePhrase;
String headerFieldName = "Content-type: ";
String headerValue;
String header;
public HTTP(String request, Socket socket) throws IOException {
StringTokenizer st = new StringTokenizer(request);
st.nextToken();
file = "." + st.nextToken();
try {
BufferedInputStream bin = new BufferedInputStream(new FileInputStream(file));
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
headerValue = contentType(file);
statusLine = "HTML/1.0 200 OK\r\n";
responseHeader = "Content-type: " + headerValue + "\r\n";
dos.writeBytes(statusLine);
dos.writeBytes(responseHeader);
dos.writeBytes("\r\n");
System.out.println(statusLine);
System.out.println(responseHeader);
System.out.println("Client requesting file: " + file);
writeEntityBody(file, bin, dos);
System.out.println("FIle: " + file + " sent successfully.");
} catch (FileNotFoundException evt) {
System.out.println(file + " not found.");
System.out.println("Requested file does not exist.");
statusCodePhrase = "404 Not Found";
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeBytes("<HTML>" + "<HEAD><TITLE>Not Found</TITLE></HEAD>"
+ "<BODY>Not Found</BODY></HTML>");
} catch (IOException evt) {
System.out.println("Bad");
}
}
private void writeEntityBody(String file, BufferedInputStream bin, DataOutputStream dos) throws IOException {
int CHUNK_SIZE = 1024;
byte[] buffer = new byte[CHUNK_SIZE];
int len;
while ((len = bin.read(buffer)) != -1) {
dos.write(buffer, 0, len);
}
bin.close();
dos.flush();
dos.close();
}
private String contentType(String file){
String extension = file.split("\\.")[2];
if(extension.equals("htm") || extension.equals("html") || extension.equals("txt")){
contentTypeLine = "text/html";
}
else if(extension.equals("jpg") || extension.equals("gif") || extension.equals("png") || extension.equals("bmp") || extension.equals("pdf")) {
contentTypeLine = "image/bmp";
}
else{
return "application/octet-stream";
}
return contentTypeLine;
}
}
So basically, my server listens for a request from the client, which is the browser, so if I type "127.0.0.1:5520/test.txt" it connects to port 5520 and requests the file "test.txt".
In terms of listening for requests and starting threads, its fine. But in the HTTP class, when my program performs these lines:
headerValue = contentType(file);
statusLine = "HTML/1.0 200 OK\r\n";
responseHeader = "Content-type: " + headerValue + "\r\n";
dos.writeBytes(statusLine);
dos.writeBytes(responseHeader);
dos.writeBytes("\r\n");
That ideally should create the header and the browser should identify that. But the browser is just writing all of that as if it were part of the message body.
I've tried it on several different browsers and these were the results:
IE: Displays statusLine, responseHeader as if it were part of the message body and displays the contents of the file.
Firefox: Throws out statusLine, displays responseHeader as part of the message body and displays the content of the file.
Chrome: ERR_INVALID_HTTP_RESPONSE
I'm not sure why the browser can't identify the header.
Hint: the protocol is called "HTTP", not "HTML".
Related
I am writing a simple web server program for class that sends files to the web browser on request. I have written as much as I could. The difficulty is getting the data written to the OutputStream. I don't know what I am missing. I couldn't get the simple request to show up on the web browser.
I wrote it to the "name" OutputStream but when I reload the tab in the browser with the URL: "http://localhost:50505/path/file.txt" or any other like that "localhost:50505" it doesn't show up what I wrote to the OutputStream "name". It is supposed to show that.
package lab11;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketImpl;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.PrintWriter;
public class main {
private static final int LISTENING_PORT = 50505;
public static void main(String[] args) {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(LISTENING_PORT);
}
catch (Exception e) {
System.out.println("Failed to create listening socket.");
return;
}
System.out.println("Listening on port " + LISTENING_PORT);
try {
while (true) {
Socket connection = serverSocket.accept();
System.out.println("\nConnection from "
+ connection.getRemoteSocketAddress());
handleConnection(connection);
}
}
catch (Exception e) {
System.out.println("Server socket shut down unexpectedly!");
System.out.println("Error: " + e);
System.out.println("Exiting.");
}
}
public static void handleConnection(Socket sok) {
try {
// Scanner in = new Scanner(sok.getInputStream());
InputStream one = sok.getInputStream();
InputStreamReader isr = new InputStreamReader(one);
BufferedReader br = new BufferedReader(isr);
String rootDirectory = "/files";
String pathToFile;
// File file = new File(rootDirectory + pathToFile);
StringBuilder request = new StringBuilder();
String line;
line = br.readLine();
while (!line.isEmpty()) {
request.append(line + "\r\n");
line = br.readLine();
}
// System.out.print(request);
String[] splitline = request.toString().split("\n");
String get = null;
String file = null;
for (String i : splitline) {
if (i.contains("GET")) {
get = i;
String[] splitget = get.split(" ");
file = splitget[1];
}
}
}
OutputStream name = sok.getOutputStream();
Boolean doesexist = thefile.exists();
if (doesexist.equals(true)) {
PrintWriter response = new PrintWriter(System.out);
response.write("HTTP/1.1 200 OK\r\n");
response.write("Connection: close\r\n");
response.write("Content-Length: " + thefile.length() + "\r\n");
response.flush();
response.close();
sendFile(thefile, name);
} else {
System.out.print(thefile.exists() + "\n" + thefile.isDirectory() + "\n" + thefile.canRead());
}
}
catch (Exception e) {
System.out.println("Error while communicating with client: " + e);
}
finally { // make SURE connection is closed before returning!
try {
sok.close();
}
catch (Exception e) {
}
System.out.println("Connection closed.");
}
}
private static void sendFile(File file, OutputStream socketOut) throws
IOException {
InputStream in = new BufferedInputStream(new FileInputStream(file));
OutputStream out = new BufferedOutputStream(socketOut);
while (true) {
int x = in.read(); // read one byte from file
if (x < 0)
break; // end of file reached
out.write(x); // write the byte to the socket
}
out.flush();
}
}
So, I don't know what I really did wrong.
When I load the browser with localhost:50505 it just says can't connect or localhost refused to connect.
You are writing the HTTP response in System.out. You should write it in name, after the headers, in the body of the response. You probably want to describe it with a Content-Type header to make the receiver correctly show the file.
I'm new to coding and Java,I have create a simple client-server program where the client can request a file. Its content will be displayed in the browser page together with some details like the data type and the length.
I'm now having a problem, I'm not sure how to display in the browser the server response for a correct connection like "HTTP/1.1 200 OK" and for the connection closed like "Connection: close".
I have a method to handle the response as follow:
import java.io.*;
import java.net.*;
import java.util.*;
public class ReadRequest {
private final static int LISTENING_PORT = 50505;
protected static Socket client;
protected static PrintStream out;
static String requestedFile;
#SuppressWarnings("resource")
public static void main(String[] args) {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(LISTENING_PORT);
}
catch (Exception e) {
System.out.println("Failed to create listening socket.");
return;
}
System.out.println("Listening on port " + LISTENING_PORT);
try {
while (true) {
Socket connection = serverSocket.accept();
System.out.println("\nConnection from "+ connection.getRemoteSocketAddress());
ConnectionThread thread = new ConnectionThread(connection);
thread.start();
}
}
catch (Exception e) {
System.out.println("Server socket shut down unexpectedly!");
System.out.println("Error: " + e);
System.out.println("Exiting.");
}
}
private static void handleConnection(Socket connection) {
String username = System.getProperty("user.name");
String httpRootDir = "C:\\Users\\"+(username)+"\\Downloads\\";
client = connection;
try {
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintStream (client.getOutputStream());
String line = null;
String req = null;
req = in.readLine();
line = req;
while (line.length() > 0)
{
line = in.readLine();
}
StringTokenizer st = new StringTokenizer(req);
if (!st.nextToken().equals("GET"))
{
sendErrorResponse(501);
return;
}
requestedFile = st.nextToken();
File f = new File(httpRootDir + requestedFile);
if (!f.canRead())
{
sendErrorResponse(404);
return;
}
sendResponseHeader(getMimeType(requestedFile),(int) f.length());
sendFile(f,client.getOutputStream());
}
catch (Exception e) {
System.out.println("Error while communicating with client: " + e);
}
finally {
try {
connection.close();
}
catch (Exception e) {
}
System.out.println("Connection closed.");
};
}
private static void sendResponseHeader(String type,int length)
{
out.println("Content-type: " +type+"\r\n");
out.println("Content-Length: " +length+"\r\n");
}
private static void sendErrorResponse(int errorCode)
{
switch(errorCode) {
case 404:
out.print("HTTP/1.1 404 Not Found");
out.println("Connection: close " );
out.println("Content-type: text/plain" +"\r\n");
out.println("<html><head><title>Error</title></head><body> <h2>Error: 404 Not Found</h2> <p>The resource that you requested does not exist on this server.</p> </body></html>");
break;
case 501:
out.print("HTTP/1.1 501 Not Implemented");
out.println("Connection: close " );
out.println("Content-type: text/plain" +"\r\n");
break;
}
}
private static String getMimeType(String fileName) {
int pos = fileName.lastIndexOf('.');
if (pos < 0)
return "g-application/x-unknown";
String ext = fileName.substring(pos+1).toLowerCase();
if (ext.equals("txt")) return "text/plain";
else if (ext.equals("html")) return "text/html";
else if (ext.equals("htm")) return "text/html";
else if (ext.equals("css")) return "text/css";
else if (ext.equals("js")) return "text/javascript";
else if (ext.equals("java")) return "text/x-java";
else if (ext.equals("jpeg")) return "image/jpeg";
else if (ext.equals("jpg")) return "image/jpeg";
else if (ext.equals("png")) return "image/png";
else if (ext.equals("gif")) return "image/gif";
else if (ext.equals("ico")) return "image/x-icon";
else if (ext.equals("class")) return "application/java-vm";
else if (ext.equals("jar")) return "application/java-archive";
else if (ext.equals("zip")) return "application/zip";
else if (ext.equals("xml")) return "application/xml";
else if (ext.equals("xhtml")) return"application/xhtml+xml";
else return "g-application/x-unknown";
}
private static void sendFile(File file, OutputStream socketOut) throws IOException {
try (InputStream infile = new BufferedInputStream(new FileInputStream(file))) {
OutputStream outfile = new BufferedOutputStream(socketOut);
while (true) {
int x = infile.read();
if (x < 0)
break;
outfile.write(x);
}
outfile.flush();
}
}
private static class ConnectionThread extends Thread {
Socket connection;
ConnectionThread(Socket connection) {
this.connection = connection;
}
public void run() {
handleConnection(connection);
}
}
}
Any suggestion on how I can do that? thank you
You make your way too complicate if you try to reinvent the wheel implementing Request/Response communication. It is better just to use the Spring MVC.
I wrote a Java server application that returns a file when it is requested by a browser. The browser makes a GET request to my socket and the socket returns the file. But the browser (firefox in my case) treats the html file as a regular text file and does not render the actual page. So the browser shows the whole html source code. How can I fix that?
Here the Code:
package ml.mindlabor.networking;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
static final int PORT = 9806;
static final int MAX_BYTES_PER_STREAM = 10_000; // 10 kB
static final String FILE_SYSTEM_PATH = "C:\\Users\\SBrau\\eclipse-workspace\\Networking\\src\\ml\\mindlabor\\networking\\Files\\public_html";
static boolean running = true;
ServerSocket ss = null;
Socket soc = null;
public static void main(String[] args) {
Server server = new Server();
// When the connection could not be established
System.out.println("Waiting for connection ...");
if (!server.connect()) return;
server.listenForResponse();
}
public Server() {
try {
ss = new ServerSocket(PORT);
} catch (IOException e) {
System.err.println("Could not create ServerSocket on Port " + PORT);
shutdown();
}
}
boolean respond(String response) {
try {
PrintWriter out = new PrintWriter(soc.getOutputStream(), true);
out.println(response);
return true;
} catch (IOException e) {
System.err.println("Could not send to Port " + PORT);
}
return false;
}
boolean respond(byte[] response) {
try {
soc.getOutputStream().write(response);
return true;
} catch (IOException e) {
System.err.println("Could not send to Port " + PORT);
}
return false;
}
boolean respondFile(String relPath) {
String path = Server.FILE_SYSTEM_PATH + relPath;
File file = new File(path);
try {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
byte[] buffer = new byte[(int)file.length()]; // or 4096, or more
in.read(buffer, 0, buffer.length);
soc.getOutputStream().write(buffer, 0, buffer.length);
System.out.println("Loaded :D");
in.close();
soc.shutdownOutput();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
String rawDataToString(byte[] rawData) {
return new String(rawData);
}
void listenForResponse() {
new Thread(() -> {
while (true) {
try {
DataInputStream in = new DataInputStream(soc.getInputStream());
byte[] packetData = new byte[MAX_BYTES_PER_STREAM];
in.read(packetData);
receivedPackage(packetData);
} catch (IOException e) {
System.err.println("Could not get data from port " + PORT);
shutdown();
}
}
}).start();
}
void shutdown() {
Server.running = false;
}
void receivedPackage(byte[] pkg) {
String request = new String(pkg).trim();
// GET Request for file
if (request.contains("GET ")) {
String[] arr = request.split(" ");
respondFile(arr[1].trim());
}
}
boolean connect() {
try {
soc = ss.accept();
//soc.setKeepAlive(true);
System.out.println("Connected!");
return true;
} catch (IOException e) {
System.err.println("Could not wait for connection on port " + PORT);
shutdown();
}
return false;
}
}
Ok. Got it. I solved it by rewriting the following method:
boolean respondFile(String relPath) {
String path = Server.FILE_SYSTEM_PATH + relPath;
File file = new File(path);
try {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
PrintWriter out = new PrintWriter(soc.getOutputStream());
BufferedOutputStream dataOut = new BufferedOutputStream(soc.getOutputStream());
byte[] fileData = readFileData(file, (int)file.length());
out.println("HTTP/1.1 501 Not Implemented");
out.println("Content-type: text/html");
out.println(); // blank line between headers and content, very important !
out.flush();
dataOut.write(fileData, 0, fileData.length);
dataOut.flush();
System.out.println("Loaded :D");
in.close();
soc.shutdownOutput();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
private byte[] readFileData(File file, int fileLength) throws IOException {
FileInputStream fileIn = null;
byte[] fileData = new byte[fileLength];
try {
fileIn = new FileInputStream(file);
fileIn.read(fileData);
} finally {
if (fileIn != null)
fileIn.close();
}
return fileData;
}
I want to access an arbitrary webpage using sockets (as a learning mechanism for myself). The code below does not work, what am I doing wrong?
import java.net.*;
import java.io.*;
public class Example
{
public static void main(String args[]) throws Exception
{
Socket socket =
new Socket("www.google.com", 80);
PrintWriter out =
new PrintWriter(socket.getOutputStream(), true);
BufferedReader reader =
new BufferedReader(
new InputStreamReader(socket.getInputStream()));
BufferedReader stdIn =
new BufferedReader(
new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println("GET / HTTP/1.1 \\r\\n Host: www.google.com \\r\\n\\r\\n");
System.out.println("echo: " + reader.readLine());
}
}
}
After trying for a couple hours I was unable to figure out what exactly I was doing wrong. All I want is Google's or some other websites homepage. Can anyone help me?
You might try something like the following (using sockets)
package com.example.webpagesocket;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
public class GetWebPageUsingSockets {
public static void main(String[] args) {
String urlString;
urlString = "www.google.com";
accessWeb(urlString);
}
private static void accessWeb(String urlString) {
String host;
String page;
int slashLoc;
// Set up encoding and decoding
Charset charset = Charset.forName("ISO-8859-1");
CharsetDecoder decoder = charset.newDecoder();
CharsetEncoder encoder = charset.newEncoder();
if ((slashLoc = urlString.indexOf('/')) < 0) {
host = urlString;
page = "";
} else {
host = urlString.substring(0, slashLoc);
page = urlString.substring(slashLoc);
}
System.out.println("Accessing web page demonstration");
System.out.println("Host: '" + host + "' Page: '" + page + "'");
SocketChannel channel = null;
try {
ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
CharBuffer charBuffer = CharBuffer.allocate(1024);
InetSocketAddress socketAddress = new InetSocketAddress(host, 80);
channel = SocketChannel.open();
channel.connect(socketAddress);
String request = "GET " + page + " \r\n\r\n";
channel.write(encoder.encode(CharBuffer.wrap(request)));
while ((channel.read(buffer)) != -1) {
buffer.flip();
decoder.decode(buffer, charBuffer, false);
charBuffer.flip();
System.out.println(charBuffer);
buffer.clear();
charBuffer.clear();
}
} catch (UnknownHostException e) {
System.err.println(e);
} catch (IOException e) {
System.err.println(e);
} finally {
if (channel != null) {
try {
channel.close();
} catch (IOException ignored) {
}
}
}
System.out.println("\nDone.");
}
}
Edit : didn't notice the \ at first reading ...
It looks like you are continuously sending "GET / HTTP/1.1 \\r\\n Host: www.google.com \\r\\n\\r\\n" to the host (at each read). You'd better keeping it out of the loop and sent true carriage return + line feed and not printable chars \ r \ n :
out.println("GET / HTTP/1.1 \r\nHost: www.google.com\r\n\r\n");
String userInput;
while ((userInput = stdIn.readLine()) != null) {
You only start reading after sending your GET, but the socket will buffer data.
I run my java webserver on port 6799
My directory has a txt.txt file and pdf.pdf file
When I give localhost:6799/txt.txt, it gives perfect output saying
GET /txt.txt HTTP/1.1HTTP/1.0 200 OK
Content-type: text/plain
This is a very simple text file
But when I give localhost:6799/pdf.pdf from browser, it gives java.lang.NullPointerException
This is my code
import java.net.*;
public final class WebServer {
public static void main(String args[]) throws Exception {
int port = 6799;
System.out.println("\nListening on port " + port);
ServerSocket listen = new ServerSocket(port);
while (true) {
Socket socket = listen.accept();
HttpRequest request = new HttpRequest(socket);
Thread thread = new Thread(request);
thread.start();
}
}
}
--
import java.io.*;
import java.net.*;
import java.util.StringTokenizer;
public final class HttpRequest implements Runnable {
final String CRLF = "\r\n";
Socket socket;
public HttpRequest(Socket socket) throws Exception {
this.socket = socket;
}
#Override
public void run() {
try {
processRequest();
} catch (Exception e) {
System.out.println(e);
}
}
private void processRequest() throws Exception {
BufferedReader br;
DataOutputStream dos;
try (InputStream is = socket.getInputStream()) {
br = new BufferedReader(new InputStreamReader(is));
String requestline = br.readLine();
System.out.println("\n" + requestline);
String headerLine = null;
while ((headerLine = br.readLine()).length() != 0) {
System.out.println(headerLine);
}
dos = new DataOutputStream(socket.getOutputStream());
dos.writeBytes(requestline);
StringTokenizer tokens = new StringTokenizer(requestline);
tokens.nextToken(); // skip over the method, which should be "GET"
String fileName = tokens.nextToken();
// Prepend a "." so that file request is within the current directory.
fileName = "." + fileName;
FileInputStream fis = null;
boolean fileExists = true;
try {
fis = new FileInputStream(fileName);
} catch (FileNotFoundException e) {
fileExists = false;
}
String statusLine = null;
String contentTypeLine = null;
String entityBody = null;
if (fileExists) {
statusLine = "HTTP/1.0 200 OK" + CRLF;
contentTypeLine = "Content-type: " + contentType(fileName) + CRLF;
} else {
statusLine = "HTTP/1.0 404 Not Found" + CRLF;
//contentTypeLine = "Content-type: " + "text/html" + CRLF;
entityBody = "<HTML>"
+ "<HEAD><TITLE>Not Found</TITLE></HEAD>"
+ "<BODY>Not Found</BODY></HTML>";
}
dos.writeBytes(statusLine);
dos.writeBytes(contentTypeLine);
dos.writeBytes(CRLF);
if (fileExists) {
sendBytes(fis, dos);
fis.close();
} else {
dos.writeBytes(entityBody);
}
}
br.close();
dos.close();
socket.close();
}
private void sendBytes(FileInputStream fis, DataOutputStream dos) throws IOException {
byte[] buffer = new byte[4096];
int bytes = 0;
while ((bytes = fis.read(buffer)) != -1) {
dos.write(buffer, 0, bytes);
}
}
private String contentType(String fileName) {
if (fileName.endsWith(".htm") || fileName.endsWith(".html")) {
return "text/html";
}
if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
return "image/jpeg";
}
if (fileName.endsWith(".gif")) {
return "image/gif";
}
if (fileName.endsWith(".txt")) {
return "text/plain";
}
if (fileName.endsWith(".pdf")) {
return "application/pdf";
}
return "application/octet-stream";
}
}
STACK TRACE
java.lang.NullPointerException
at java.io.DataOutputStream.writeBytes(DataOutputStream.java:274)
at HttpRequest.processRequest(HttpRequest.java:65)
at HttpRequest.run(HttpRequest.java:20)
at java.lang.Thread.run(Thread.java:724)
At least one issue is this code:
while ((headerLine = br.readLine()).length() != 0) {
System.out.println(headerLine);
}
BufferedReader will return null at the end of the stream, so calling .length() on a null object will yield a NullPointerException.
A more idiomatic way to write this is:
while ((headerLine = br.readLine()) != null && headerLine.length() != 0) {
System.out.println(headerLine);
}
...which takes advantage of short-circuit logic to not evaluate the second condition if the result of (headerLine = br.readLine()) is null.
It is happening because for some reason you have toggled comment on the following line:
//contentTypeLine = "Content-type: " + "text/html" + CRLF;
Untoggle it and you're good!